<template>
    <div id="app">
        <template v-if="route.path.startsWith('/user')">
            <router-view />
        </template>
        <template v-else>
            <BasicLayout />
            <FloatButton
                @click="onFloatButtonClick"
                v-show="!visible"
                type="primary"
                description="AI"
            ></FloatButton>
            <ChatDrawer :onClose="onDrawerClose" :visible="visible" />
        </template>
    </div>
</template>

<style>
#app {
}
</style>
<script setup lang="ts">
import BasicLayout from "@/layouts/BasicLayout.vue";
import { onMounted, ref } from "vue";
import { useRoute } from "vue-router";
import ChatDrawer from "./components/ChatDrawer.vue";
import { FloatButton } from "ant-design-vue";

const route = useRoute();

const visible = ref(false);

const onFloatButtonClick = () => {
    visible.value = true;
};

const onDrawerClose = () => {
    visible.value = false;
};

/**
 * 全局初始化函数，有全局单次调用的代码，都可以写到这里
 */
const doInit = () => {
    console.log("hello 欢迎来到我的项目");
};

onMounted(() => {
    doInit();
});
</script>
